package servlet;

import model.ClassInfo;
import service.ClassInfoService;
import service.UseInfoService;
import utils.MyBatisUtil;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "SelectClassInfoServlet", value = "/SelectClassInfoServlet")
public class SelectClassInfoServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ClassInfoService cis = new ClassInfoService();
        request.setAttribute("classes", cis.findAll());
//        for (ClassInfo classInfo : cis.findAll()) {
//            System.out.println(classInfo);
//        }
        MyBatisUtil.closeSession();
        request.getRequestDispatcher("/classes.jsp").forward(request, response);
    }
}
